package com.xyz.controller;

import com.xyz.aop.ObjectParam;
import com.xyz.dto.BusinessAnnounceDto;
import com.xyz.dto.CountDto;
import com.xyz.service.AnnounceService;
import com.xyz.service.HomeMaintenService;
import com.xyz.util.dto.DataResult;
import com.xyz.util.dto.LoginInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("homeMainten")
public class HomeMaintenController {

    private static final Logger logger = LoggerFactory.getLogger(HomeMaintenController.class);

    @Autowired
    private HomeMaintenService homeMaintenService;

    /*
    * 维修看板-头部信息
    * */
    @PostMapping("/selectHeadRo")
    public DataResult selectHeadRo(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectHeadRo(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectHeadRo", e);
            return DataResult.build9500();
        }
    }

    /*
     * 维修看板-故障曲线图
     * */
    @PostMapping("/selectFault")
    public DataResult selectFault(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectFault(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectFault", e);
            return DataResult.build9500();
        }
    }

    /*
     * 人员工单排行
     * */
    @PostMapping("/selectRoPersonRanking")
    public DataResult selectRoPersonRanking(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectRoPersonRanking(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectRoPersonRanking", e);
            return DataResult.build9500();
        }
    }

    /*
     * 人员评分排行
     * */
    @PostMapping("/selectScorePersonRanking")
    public DataResult selectScorePersonRanking(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectScorePersonRanking(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectScorePersonRanking", e);
            return DataResult.build9500();
        }
    }

    /*
     * 设备故障类型分布饼状图
     * */
    @PostMapping("/selectFaultPie")
    public DataResult selectFaultPie(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectFaultPie(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectFaultPie", e);
            return DataResult.build9500();
        }
    }

    /*
     * 设备故障原因分析
     * */
    @PostMapping("/selectReason")
    public DataResult selectReason(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectReason(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectReason", e);
            return DataResult.build9500();
        }
    }

    /*
     * 维修来源分析
     * */
    @PostMapping("/selectRepairSource")
    public DataResult selectRepairSource(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectRepairSource(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectRepairSource", e);
            return DataResult.build9500();
        }
    }

    /*
     * 备件使用排行
     * */
    @PostMapping("/selectPartRanking")
    public DataResult selectPartRanking(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectPartRanking(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectPartRanking", e);
            return DataResult.build9500();
        }
    }

    /*
     * 设备维修排行
     * */
    @PostMapping("/selectEmRanking")
    public DataResult selectEmRanking(LoginInfo loginInfo,@ObjectParam CountDto countDto) {
        try {
            return homeMaintenService.selectEmRanking(loginInfo,countDto);
        } catch (Exception e) {
            logger.error("selectEmRanking", e);
            return DataResult.build9500();
        }
    }

}
